package food;

import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

public class RedTest extends Reducer<food, NullWritable, food, NullWritable> {
    food k = new food();
    int dis_sum = 0;
    int pap_sum = 0;

    @Override
    protected void reduce(food key, Iterable<NullWritable> values, Context context) throws IOException, InterruptedException {
        for (NullWritable v : values) {
            dis_sum += key.getDicuss();
            pap_sum += key.getPapularition();
        }
        k.set(key.getFoodName(),dis_sum,pap_sum);
        context.write(k, NullWritable.get());
        dis_sum = 0;
        pap_sum = 0;

    }
}
